package com.jdb.settings.privoder.service.impl;

import com.guns21.result.domain.Result;
import com.jdb.settings.api.SettingDTO;
import com.jdb.settings.controller.assembler.SettingAssembler;
import com.jdb.settings.privoder.entity.SettingDO;
import com.jdb.settings.privoder.repository.SettingRepository;
import com.jdb.settings.privoder.service.SettingsQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SettingsQueryServiceImpl implements SettingsQueryService {
    @Autowired
    private SettingRepository settingRepository;
    @Override
    public Result<SettingDTO> get(String key) {
        SettingDO settingDO = settingRepository.findByKey(key).orElse(null);
        return Result.success(SettingAssembler.toDTO(settingDO));
    }
}
